*     *****************************************************************  * 
*     *****************************************************************  * 
*       File-Name:      recode.do                                        *  
*       Date:           1 June 2016                                      * 
*       Author:         Gschwend                                         * 
*       Purpose:      	aggregate country studies as well as             *
*                       Fig 6.1 & 6.2 and Table 6.1					     *
* 	    Input Files:    recode.dta                                       *
*       Data Output:    party.dta                                        *              
*     ****************************************************************   * 
*     ****************************************************************   * 



version 14.2
clear
capture log close
set more off



**********************************************
* Specify your own local path to the dropbox *
**********************************************


* Thomas G.'s local (office) path:
* local path /Users/gschwend/Dropbox/Andre/OUP multilevel electoral behavior book/chapter 6/replication/


* Thomas G.'s local (Air) path:
* local path /Users/thomasgschwend/Dropbox/Andre/OUP multilevel electoral behavior book/chapter 6/replication/
 
 
 
use recode, clear




sum prefPartyNum1
return list
assert r(N)== 21079  & r(min)==1 & r(max)==9 




gen level_new = 1 if LEVEL=="National"
replace level_new = 2 if LEVEL=="Regional"
replace level_new = 3 if LEVEL=="European"

label define level_new 2 "Regional" 1 "National" 3 "Euopean"
label value level_new level_new

gen national = (level_new==1)
gen regional = (level_new==2)
gen european = (level_new==3)


label define COUNTRY 1 "France" 2 "Germany" 3 "Spain"
label value COUNTRY COUNTRY

gen Germany = (COUNTRY==2)
gen Spain   = (COUNTRY==3)
gen France  = (COUNTRY==1)


**********************
** Sincere voter
**********************



gen sincere = .
replace sincere = 1 if prefPartyNum1 == Q8 
replace sincere = 0 if prefPartyNum1 != Q8 
replace sincere = 0 if TiePartyPref12==1
*replace sincere = 0 if prefPartyNum1 != Q8 & prefPartyNum2 == Q8 & TiePartyPref12==1

fre sincere
tab sincere COUNTRY, col
tab sincere level_new, col

**********************
** Strategic voter
**********************


/*
A voter is coded as if she follows the wasted-vote strategy if she 
(1) does not cast her vote for the most preferred party, 
(2) her most-preferred party is not expected to be viable, i.e. is 
    not expected to win at least one seat in the voter’s electoral district and, 
(3) she votes for a party instead that is expected to gain representation
*/


fre seat_current0MP1 prefPartyNum1 Q8 seat_current0



gen wasted1 = (prefPartyNum1 != Q8 & seat_current0MP1 ==1 & seat_current0 ==0)
label var wasted1 "wasted vote (=1)"
fre wasted1

tab wasted1 eid, col
tab wasted1 COUNTRY, col
tab wasted1 level_new, col




/*
A voter is coded as if she follows the wasted-vote strategy if she 
(1) does not cast her vote for the most preferred party (because there are two tied for first prefernce), 
(2) her most-preferred party (at least one if there is a tie) is not expected to be viable, i.e. is 
    not expected to win at least one seat in the voter’s electoral district and, 
(3) she votes for a party instead that is expected to gain representation
*/

* Only tie between top two parties
gen tie12 = (TiePartyPref12==1 & TiePartyPref13==0)

* wasted vote for ties
gen wasted2 = (prefPartyNum1 == Q8 &  prefPartyNum2 != Q8 & tie12==1 ///
               & (seat_current0MP1 ==1 | seat_current0MP2 ==1) & seat_current0 ==0)

			   
gen wasted= wasted1 + wasted2
label var wasted "wasted vote (=1) incl. ties"

fre wasted wasted1

tab wasted eid, col
tab wasted1 eid, col

tab wasted COUNTRY, col
tab wasted1 COUNTRY, col

tab wasted level_new, col
tab wasted1 level_new, col
   
			   
*spineplot wasted level_new




*(3) cast her vote for the most preferred among the large parties

gen id1 = eid*100 + pref1
gen id2 = eid*100 + pref2
gen id3 = eid*100 + pref3
gen id4 = eid*100 + pref4
gen id5 = eid*100 + pref5
gen id6 = eid*100 + pref6
gen id7 = eid*100 + pref7
gen id8 = eid*100 + pref8
gen id9 = eid*100 + pref9

gen caseid = _n
sort id1 caseid
merge m:1 id1 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty1
drop _merge caseid

gen caseid = _n
sort id2 caseid
merge m:1 id2 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty2
drop _merge caseid

gen caseid = _n
sort id3 caseid
merge m:1 id3 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty3
drop _merge caseid

gen caseid = _n
sort id4 caseid
merge m:1 id4 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty4
drop _merge caseid

gen caseid = _n
sort id5 caseid
merge m:1 id5 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty5
drop _merge caseid

gen caseid = _n
sort id6 caseid
merge m:1 id6 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty6
drop _merge caseid

gen caseid = _n
sort id7 caseid
merge m:1 id7 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty7
drop _merge caseid

gen caseid = _n
sort id8 caseid
merge m:1 id8 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty8
drop _merge caseid

gen caseid = _n
sort id9 caseid
merge m:1 id9 using  "large_party.dta"
drop if _merge==2
ren largeparty largeparty9
drop _merge caseid



forvalues v = 1(1)9 {
       label var largeparty`v' "`v'. most preferred party is large (=1)"
	   }



gen pref_largeparty	 = .
replace  pref_largeparty = 1 if largeparty1==1 & pref_largeparty==.
replace  pref_largeparty = 2 if largeparty2==1 & pref_largeparty==.
replace  pref_largeparty = 3 if largeparty3==1 & pref_largeparty==.
replace  pref_largeparty = 4 if largeparty4==1 & pref_largeparty==.
replace  pref_largeparty = 5 if largeparty5==1 & pref_largeparty==.
replace  pref_largeparty = 6 if largeparty6==1 & pref_largeparty==.
replace  pref_largeparty = 7 if largeparty7==1 & pref_largeparty==.
replace  pref_largeparty = 8 if largeparty8==1 & pref_largeparty==.	 
replace  pref_largeparty = 9 if largeparty9==1 & pref_largeparty==. 

label var pref_largeparty "number of most preferred large party"

fre pref_largeparty

/*
A voter is coded as a strategic coalition voter if she 
(1) does not vote for their most preferred party, while 
(2) this party is viable to get a seat but
(3) not expected to be a viable candidate for one of the two strongest parties, and 
(4) cast her vote for the most preferred among the large parties 



Catelonia regional election more than two large parties.
PSC(20)
PP(19)

CiU (50)
ERC (21seats) 
*/

gen coalition1 = (prefPartyNum1 != Q8 & seat_current0MP1 !=1 & large_partyMP1 !=1 & pref_largeparty== Q8)
label var coalition1 "coalition vote (=1)"
fre coalition1

tab coalition1 eid, col
tab coalition1 COUNTRY, col
tab coalition1 level_new, col

* coalition vote for ties

/*
A voter is coded as a strategic coalition voter if she 
(1) does not vote for their most preferred party (because there are two tied for first prefernce), while 
(2) this party (or both if there is a tie) is viable to get a seat but
(3) not expected (at least one if there is a tie) to be a viable candidate for one of the two strongest parties, and 
(4) cast her vote for the most preferred among the large parties  
*/



gen coalition2 = (prefPartyNum1 == Q8 &  prefPartyNum2 != Q8 & tie12==1  ///
               & (seat_current0MP1 ==0 & seat_current0MP2 ==0)          ///
			   & (large_partyMP1 !=1 | large_partyMP2 !=1)             ///
			   &  pref_largeparty== Q8)

		   
gen coalition= coalition1 + coalition2
label var coalition "coalition vote (=1) incl. ties"

fre coalition coalition1

tab coalition eid, col
tab coalition1 eid, col

tab coalition COUNTRY, col
tab coalition1 COUNTRY, col

tab coalition level_new, col
tab coalition1 level_new, col



* Check data consistency (Replicates with the same recode.dta)

sum wasted
return list
assert r(N)== 21079  & r(min)==0 & r(max)==1 & r(sum) ==   10535


sum coalition
return list
assert r(N)== 21079  & r(min)==0 & r(max)==1 & r(sum) ==  407

 

   
   
gen strategic = coalition + wasted
fre strategic
tab strategic COUNTRY, col
tab strategic level_new, col


/*
estpost tabstat   wasted coalition strategic sincere, by(COUNTRY) ///
     statistics(mean) columns(statistics) 
eststo est0

esttab est0 using descriptive0.rtf, main(mean %8.3f)   nostar unstack rtf ///
     noobs nonote nomtitle nonumber replace label ///
     varlabels( sincere "Sincere Voters" strategic "Strategic Voters" wasted "Wasted Vote" ///
          coalition "Coalition Vote" ) ///
		  title ("Table X.2: Sincere and Strategic Voting across Countries") ///
	 addnote ("N = `e(N)'")
	


estpost tabstat   wasted coalition strategic sincere, by(level_new) ///
     statistics(mean) columns(statistics) 
eststo est0

esttab est0 using descriptive1.rtf, main(mean %8.3f)   nostar unstack rtf ///
     noobs nonote nomtitle nonumber replace label ///
     varlabels( sincere "Sincere Voters" strategic "Strategic Voters" wasted "Wasted Vote" ///
          coalition "Coalition Vote" ) ///
		  title ("Table X.2: Sincere and Strategic Voting across Electoral Arenas") ///
	 addnote ("N = `e(N)'")
*/




*************************
** Individual analysis **
*************************


* create measures of perceived importance of the actual election
gen importance = .
replace importance = importance_regional if regional==1
replace importance = importance_national if national==1
replace importance = importance_european if european==1

* rel. importance as compared to national election

gen rel_importance = .
replace rel_importance = importance_regional - importance_national if regional==1
replace rel_importance = 0 if national==1
replace rel_importance = importance_european - importance_national if european==1

* individual z-scores

egen mean_imp = rowmean(importance_regional importance_national importance_european)
egen sd_imp = rowsd(importance_regional importance_national importance_european)

gen zimportance_r = (importance_regional - mean_imp)/sd_imp
gen zimportance_n = (importance_national - mean_imp)/sd_imp
gen zimportance_e = (importance_european - mean_imp)/sd_imp

gen zimportance = .
replace zimportance = zimportance_r if regional==1
replace zimportance = zimportance_n if national==1
replace zimportance = zimportance_e if european==1


logit sincere spid polknow importance tie12 european regional Germany Spain
logit sincere spid polknow rel_importance tie12 european regional Germany Spain

* Expectation: viable party is most preferred
gen viable = (seat_current0!=1)

gen non_viable = (seat_current0==1)
gen non_viable_imp = non_viable*importance
gen non_viable_zimp = non_viable*zimportance




* Controlls, spid, polknow

recode spid .=0 /* Recode those without pid has having spid=0 */

gen imp_spid = importance*spid
gen imp_know = importance*polknow

logit sincere non_viable zimportance non_viable_zimp european Germany Spain
logit sincere non_viable zimportance non_viable_zimp spid polknow european Germany Spain

logit sincere non_viable importance non_viable_imp  Germany Spain
logit sincere non_viable importance non_viable_imp european Germany Spain
logit sincere non_viable importance non_viable_imp spid polknow european Germany Spain


logit coalition importance spid polknow national Germany Spain
estat classification






fre coalition if e(sample)

/* rare events is not quite a problem here:
"The problem is not specifically the rarity of events, but rather the possibility of a small number of cases 
on the rarer of the two outcomes.  If you have a sample size of 1000 but only 20 events, 
you have a problem. If you have a sample size of 10,000 with 200 events, you may be OK. 
If your sample has 100,000 cases with 2000 events, you’re golden.

There’s nothing wrong with the logistic model in such cases. The problem is that maximum likelihood estimation 
of the logistic model is well-known to suffer from small-sample bias. And the degree of bias 
is strongly dependent on the number of cases in the less frequent of the two categories. So even with 
a sample size of 100,000, if there are only 20 events in the sample, you may have substantial bias."


Logistic Regression for Rare Events
February 13, 2012 By Paul Allison
http://statisticalhorizons.com/logistic-regression-for-rare-events
*/



***********************************
** Balancing between between arenas
***********************************


gen importance_n = (importance_national> importance_regional & importance_national>importance_european)
replace importance_n = . if importance_national==.
gen importance_r = (importance_regional> importance_national & importance_regional>importance_european)
replace importance_r = . if importance_national==.
gen importance_e = (importance_european> importance_national & importance_european>importance_regional)
replace importance_e = . if importance_national==.

gen tie_imp_nr = (importance_national==importance_regional & importance_national!=.)
gen tie_imp_ne = (importance_national==importance_european & importance_national!=.)
gen tie_imp_re = (importance_regional==importance_european & importance_regional!=.)



* suporter of goverment in most important election deviates from it

gen balance = 0
replace balance = 1 if (importance_n==1 & incumbent_nationalMP1 ==1 & incumbent_national==0 & regional==1)
replace balance = 1 if (importance_r==1 & incumbent_regionalMP1 ==1 & incumbent_regional==0 & national==1)
recode balance 0=. if importance_n==. | importance_r==.
* no incumbernt gov for Eurupean elections




***********************************
** Protest against national gOvt
***********************************

* suporter of national goverment  deviates from it in regional & european election

gen protest = 0
replace protest = 1 if (incumbent_nationalMP1 ==1 & incumbent_national==0 & national!=1)
* no incumbernt gov for Eurupean elections

bysort importance_n: fre balance




tab eid balance , row
tab eid protest , row

tab balance COUNTRY, col
tab protest COUNTRY, col

tab balance level_new, col
tab protest level_new, col






/*
forvalues v = 1(1)9 {
	   gen nonsincere_`v' =.
	   replace nonsincere`_v' = 1 if prefPartyNum1 != `v' & vote`v'==1 
	   replace nonsincere_`v' = 0 if prefPartyNum1 == `v' & vote`v'==1
	   replace nonsincere_`v' = 1 if prefPartyNum1 == `v' & vote`v'==1 & prefPartyNum2 != `v' & TiePartyPref12==1
	   replace nonsincere_`v' = 0 if prefPartyNum1 != `v' & vote`v'==1 & prefPartyNum2 == `v' & TiePartyPref12==1
       label var nonsincere_`v' "Non-sincere (=1) vote for party `v'"
	   }

*/


compress

save individual, replace 




collapse (mean) sincere strategic wasted coalition  level_new COUNTRY, by(eid)




replace strategic  = strategic*100
replace wasted = wasted*100
replace coalition = coalition*100
replace sincere = sincere*100

label define level_new1 2 "Regional" 1 "National" 3 "Euopean"
label value level_new level_new1

gen national = (level_new==1)
gen regional = (level_new==2)
gen european = (level_new==3)


label define COUNTRY1 1 "France" 2 "Germany" 3 "Spain"
label value COUNTRY COUNTRY1

gen Germany = (COUNTRY==2)
gen Spain   = (COUNTRY==3)
gen France  = (COUNTRY==1)



save party, replace 




/*
#delimit ;
graph box strategic, over(level_new)
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
		graphregion(fcolor(white)) 
		ylabel(0(1)10, labsize(small) angle(horizontal) nogrid) yscale(nofextend) 
		plotregion(lcolor(white) margin(l=4))
saving(box1, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export box1.pdf, replace
*/


*graph box nonsincere1, over(level_new)

label define eid 101 "IDF (R)" 102 "Provence (R)"         ///
                 111 "IDF (N)" 112 "Provence (N)"         ///
                 131 "IDF (E)" 132 "Provence (E)"         ///
                 201 "Lower Saxony (R)" 202 "Bavaria (R)" ///
                 211 "Lower Saxony (N)" 212 "Bavaria (N)" ///
                 231 "Lower Saxony (E)" 232 "Bavaria (E)" ///				 
				 301 "Catalonia (R)" 302 "Madrid (R)"     ///
                 311 "Catalonia (N)" 312 "Madrid (N)"     ///
                 331 "Catalonia (E)" 332 "Madrid (E)"
				 
label value eid eid




/*

#delimit ;
twoway scatter strategic  COUNTRY, mlabel(level_new)
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline titlegap(1) )  
	ytitle("Share of Strategic Voters")              // incl. axis titles
	ylabel(0(2)14, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel( .5 " " 1 "France" 1.5 " " 2 "Germany" 2.5 " " 3 "Spain" 3.5" ", notick)                                    // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(graph1, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export graph1.pdf, replace

reg strategic european regional 
eststo est0
reg strategic european regional Germany Spain
eststo est1



#delimit ;
esttab est0 est1 using strategic_arenas.rtf, replace b(%9.2f) se(%9.2f)  rtf  noobs star(* 0.10 ** 0.05)
title ("Table X.1: Strategic Voting across Electoral Arenas")
varlabels(_cons "Constant" nonsincere1 "Non-Sincere" european "European" regional "Regional"
          Germany "Germany" Spain "Spain" )
stats(r2) sfmt(%9.0f)  sca("r2 R-squared") nonotes
addnote ("N = `e(N)'. Standard errors in parentheses. * p < 0.10, ** p < 0.05")
order(european regional Germany Spain)
;
#delimit cr

capture drop pos
generate pos = 3
replace pos=9 if COUNTRY==1 
replace pos=3 if inlist(eid, 101, 111, 131)
replace pos=9 if eid==212 | eid==232 | eid == 312
replace pos=1 if eid==332


#delimit ;
twoway scatter strategic  COUNTRY, mlabel(eid) mlabvpos(pos)  msize(.8) 
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline)  
	ytitle("Share of Strategic Voting")              // incl. axis titles
	ylabel(0(2)14, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel(0 " " 1 "France" 2 "Germany" 3 "Spain" 4 " ", noticks)                                    // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(scatter_sincere1, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export scatter_strategic1.pdf, replace


*/



******************** Strategic Coalition Voting ***************************************************************************


tab eid coalition

capture drop pos
generate pos = 3
replace pos=9 if COUNTRY==1 
replace pos=3 if inlist(eid, 101, 111, 131)
replace pos=9 if eid==202 
*replace pos=9 if eid==212 | eid==232 | eid == 312
*replace pos=1 if eid==332






******************
*** Figure 6.2 ***
******************


#delimit ;
twoway scatter coalition  COUNTRY if coalition>0, mlabel(eid) mlabvpos(pos)  msize(.8) 
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline)  
	ytitle("Share of Strategic Coalition Voting")              // incl. axis titles
	ylabel(0(2)8, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel(0 " " 1 "France" 2 "Germany" 3 "Spain" 4 " ", noticks)                                    // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(hyp4, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	


graph export hyp4.tif, replace
graph export hyp4.pdf, replace
graph export hyp4.png, replace
graph export hyp4.eps, replace preview(on)


/*
gen nationalSpain = national*Spain


reg coalition national  if Spain==1 & european!=1

reg coalition national 
eststo est0
reg coalition national regional Germany Spain
eststo est1
reg coalition  national               if european!=1
eststo est2
reg coalition  national Germany Spain if european!=1
eststo est3


#delimit ;
esttab  est2 est3 using coalition_arenas.rtf, replace b(%9.2f) se(%9.2f)  rtf  noobs star(* 0.10 ** 0.05)
title ("Table X.1: Strategic Coalition Voting across Electoral Arenas")
varlabels(_cons "Constant" nonsincere1 "Non-Sincere" european "European" regional "Regional" national "National"
          Germany "Germany" Spain "Spain" )
stats(r2) sfmt(%9.0f)  sca("r2 R-squared") nonotes
addnote ("N = `e(N)'. Standard errors in parentheses. * p < 0.10, ** p < 0.05")
order(national Germany Spain)
;
#delimit cr


*/



********* wasted vote *****************************************************************************************************


capture drop pos
generate pos = 3
replace pos=9 if COUNTRY==1 
replace pos=3 if inlist(eid, 131)
replace pos=9 if eid==232 
replace pos=1 if eid==332
replace pos=5 if eid==331



******************
*** Figure 6.1 ***
******************



#delimit ;
twoway scatter wasted  COUNTRY if wasted>0, mlabel(eid) mlabvpos(pos)  msize(.8) 
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline)  
	ytitle("Share of Voters using Wasted Vote Strategy")              // incl. axis titles
	ylabel(0(2)10, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel(0 " " 1 "France" 2 "Germany" 3 "Spain" 4 " ", noticks)                                    // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(scatter_wasted, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	

graph export hyp1.tif, replace
graph export hyp1.pdf, replace
graph export hyp1.png, replace
graph export hyp1.eps, replace preview(on)



reg wasted european  
eststo est0
reg wasted european  Germany Spain
eststo est1
*reg wasted european regional Germany Spain
*eststo est2




*****************
*** Table 6.1 ***
*****************

#delimit ;
esttab est0 est1  using hyp1.rtf, replace b(%9.2f) se(%9.2f)  rtf  noobs star(* 0.10 ** 0.05)
title ("Table 6.1: Voters using Wasted Vote Strategy across Regions and Electoral Arenas")
varlabels(_cons "Constant" nonsincere1 "Non-Sincere" european "EP Election" regional "Regional"
          Germany "Germany" Spain "Spain" )
stats(r2) sfmt(%9.0f)  sca("r2 R-squared") nonotes
addnote ("N = `e(N)'. Standard errors in parentheses. * p < 0.10, ** p < 0.05")
order(european  Germany Spain)
;
#delimit cr








exit
/* Old code



************ Sincere Voting


#delimit ;
graph box sincere, over(level_new)
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
		graphregion(fcolor(white)) 
		ylabel(70(10)100, labsize(small) angle(horizontal) nogrid) yscale(nofextend) 
		plotregion(lcolor(white) margin(l=4))
saving(boxsincere, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export boxsincere.pdf, replace




capture drop pos
generate pos = 3
replace pos=9 if COUNTRY==1 
replace pos=3 if inlist(eid, 101, 111, 131)
replace pos=9 if eid==212 | eid== 202
replace pos=11 if eid==102 


#delimit ;
twoway scatter sincere  COUNTRY, mlabel(eid) mlabvpos(pos) msize(.8) 
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline)  
	ytitle("Share of Sincere Voting")              // incl. axis titles
	ylabel(50(10)90, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel(0 " " 1 "France" 2 "Germany" 3 "Spain" 4 " ", noticks)                                    // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(scatter_sincere1, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export scatter_sincere1.pdf, replace




#delimit ;
twoway scatter sincere  COUNTRY, mlabel(level_new)
	legend(off)        // get rid of legend
	scheme(s1mono)     // use white background to save ink graphregion(color(white))
	xtitle(" ", color(black) alignment(bottom )) xscale(noline)  
	ytitle("Share of Sincere Voting")              // incl. axis titles
	ylabel(50(10)80, labsize(small) angle(horizontal)) yscale(nofextend)  // use smaler & readable labels
	xlabel(0 " " 1 "France" 2 "Germany" 3 "Spain" 4 " ", noticks)                                   // use less labels
		graphregion(fcolor(white)) 
	plotregion(lcolor(white) margin(l=4))	/* get rid of box (give it the same color as the background) except the axes & increase left margin*/
saving(scatter_sincere, replace);                                 // - , replace - to let the graph be replaced by a new one
#delimit cr	
graph export scatter_sincere.pdf, replace


reg sincere european regional 
eststo est0
reg sincere european regional Germany Spain
eststo est1



#delimit ;
esttab est0 est1  using sincere_areas.rtf, replace b(%9.2f) se(%9.2f)  rtf  noobs star(* 0.10 ** 0.05)
title ("Table X.2: Sincere Voting across Electoral Arenas")
varlabels(_cons "Constant" sincere "Sincere Voting" european "European" regional "Regional"
          Germany "Germany" Spain "Spain" )
stats(r2) sfmt(%9.0f)  sca("r2 R-squared") nonotes
addnote ("N = `e(N)'. Standard errors in parentheses. * p < 0.10, ** p < 0.05")
order(european regional Germany Spain)
;
#delimit cr

